/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package checador;

/**
 *
 * @author josepereyra
 */

import javax.swing.JLabel;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.text.DateFormat;

public class reloj extends JLabel implements Runnable{
    
    private Thread t;
    private String formato;
    
    @Override
    public void run(){
        while (true){
            DateFormat xFormato = new SimpleDateFormat(formato);
            Date fecha = new Date();
            this.setText(xFormato.format(fecha));
            try{
                Thread.sleep(1000);
            }
            catch(InterruptedException e){
            e.printStackTrace();
            }
                
        }
        
    }
    
    
    public reloj(){
    
        t = new Thread(this);
        formato = "HH:mm:ss";
        t.start();
            
    }
    
    public reloj(String strFormato){
    
        t= new Thread(this);
        formato = strFormato;
        t.start(); 
    
    }


}
